Skip to content

TypeScript HTTP handlers#4931

Open
gefjon wants to merge 4 commits intophoebe/http-handlers-webhooksfrom
phoebe/http-handler/v8-host
Open

TypeScript HTTP handlers#4931
gefjon wants to merge 4 commits intophoebe/http-handlers-webhooksfrom
phoebe/http-handler/v8-host

Conversation

@gefjon
Copy link
Copy Markdown
Contributor

@gefjon gefjon commented May 1, 2026

Based on #4636 .

Description of Changes

This commit adds host support for registering HTTP handlers in V8 modules, and a minimal draft of TypeScript bindings support for the same. The TypeScript bindings support is fully vibe-coded and unreviewed, and is present only to allow a new smoketest, which is added to the http_routes suite. The host changes were also AI-assisted, but I reviewed and polished them.

API and ABI breaking changes

Adds new TypeScript "ABI." Also adds a new API, which I sure hope will be overwritten by @JasonAtClockwork .

Expected complexity level and risk

2: pretty simple extensions to TypeScript execution, which largely mirror existing call_procedure machinery.

Testing

  • New smoketest.

This commit adds host support for registering HTTP handlers in V8 modules,
and a minimal draft of TypeScript bindings support for the same.
The TypeScript bindings support is fully vibe-coded and unreviewed,
and is present only to allow a new smoketest, which is added to the `http_routes` suite.
The host changes were also AI-assisted, but I reviewed and polished them.
Copy link
Copy Markdown
Collaborator

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, but overall LGTM

Comment on lines +51 to +53
type RouterWithRoutes = Router & {
[routesSymbol]: Route[];
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant?

Comment on lines +48 to +49
const routesSymbol = Symbol('SpacetimeDB.http.routes');
const httpHandlerSymbol = Symbol('SpacetimeDB.http.handler');
Copy link
Copy Markdown
Collaborator

@coolreader18 coolreader18 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What purpose do these serve? httpHandlerSymbol seems unused and routesSymbol could just be a private field on Router with a static method to access it.

};
}

export function makeHttpNamespace(ctx: SchemaInner) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice for the return value of this function (and thus also the Schema.http field) to be explicitly typed with an interface, rather than just inferred from the body.

Copy link
Copy Markdown
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; I have no comments beyond Noa's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants